<!--采购记录-->
<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="68px">
      <el-form-item label="店铺名称" prop="shopName">
        <el-input
          v-model="queryParams.shopName"
          placeholder="请输入店铺名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item label="支付方式" prop="payType">
        <dict-select :options="dict.type.pay_type" v-model="queryParams.payType" placeholder="请选择交易方式"></dict-select>
      </el-form-item>
      <el-form-item label="商品名称" prop="goodsName">
        <el-input
          v-model="queryParams.goodsName"
          placeholder="请输入商品名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="infoList">
      <el-table-column label="店铺" align="center" prop="shopName" width="160" :show-overflow-tooltip="true"/>
      <el-table-column label="商品" align="left" prop="goodsName" width="400" :show-overflow-tooltip="true"/>
      <el-table-column label="支付方式" align="center" prop="payType" width="160" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag  :options="dict.type.pay_type" :value="scope.row.payType"></dict-tag>
        </template>
      </el-table-column>
      <el-table-column label="采购单价" align="center" prop="price" width="160" :show-overflow-tooltip="true">
        <template slot-scope="scope">{{$yun.priceFormatter(scope.row.price)}}</template>
      </el-table-column>
      <el-table-column label="采购数量" align="center" prop="totalNum" width="160" :show-overflow-tooltip="true"/>
      <el-table-column label="下单时间" align="center" prop="createTime" width="180" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{m}/{d}/{y}') }}</span>
        </template>
      </el-table-column>
<!--      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="160">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-edit" @click="showDetails(scope.row)">详情</el-button>
        </template>
      </el-table-column>-->
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.current"
      :limit.sync="queryParams.size"
      @pagination="getList"
    />
    <!-- 采购信息详情 todo-->
<!--    <el-dialog title="记录详情" :visible.sync="openDetails" width="1400px" append-to-body :close-on-click-modal="false">
      <el-card class="box-card">
        <div>
          <el-row class="mb8">
            采购信息
          </el-row>
          <el-row>
            <el-col :span="4">
              用户名
            </el-col>
            <el-col :span="20">
              {{detailsObj.info.username}}
            </el-col>
          </el-row>
          <el-row>
            <el-col :span="4">店铺名称</el-col>
            <el-col :span="20">{{detailsObj.info.shopName}}</el-col>
          </el-row>
          <el-row>
            <el-col :span="4">收货人</el-col>
            <el-col :span="20">{{detailsObj.info.recipients}}</el-col>
          </el-row>
          <el-row>
            <el-col :span="4">手机号</el-col>
            <el-col :span="20">{{detailsObj.info.recipientsMobile}}</el-col>
          </el-row>
          <el-row>
            <el-col :span="4">收货地址</el-col>
            <el-col :span="20">{{detailsObj.info.recipientsAddress}}</el-col>
          </el-row>
          <el-row>
            <el-col :span="4">数量</el-col>
            <el-col :span="20">{{detailsObj.info.totalNum}}</el-col>
          </el-row>
          <el-row>
            <el-col :span="4"></el-col>
          </el-row>
        </div>
      </el-card>

    </el-dialog>-->
  </div>
</template>

<script>
import { listInfo, getInfo} from "@/api/store/purchaseRecord";
import Template from '@/views/setting/template/index.vue'

export default {
  name: "Info",
  components: { Template },
  dicts:['pay_type'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // 【请填写功能名称】表格数据
      infoList: [],
      // 查询参数
      queryParams: {
        current: 1,
        size: 10,
        shopId:null,
      },
      openDetails:false,
      shopId:null,
      detailsObj:{},
    };
  },
  created() {
    this.queryParams.shopId = this.$route.query.shopId || null;
    this.getList();
  },
  methods: {
    /** 查询【请填写功能名称】列表 */
    getList() {
      this.loading = true;
      listInfo(this.queryParams).then(response => {
        this.infoList = response.data.records;
        this.total = response.data.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.current = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.queryParams.shopId = null;
      this.handleQuery();
    },
    /** 查看详情 */
    showDetails(row) {
      getInfo(row.id,row.skuId).then(response => {
        this.detailsObj = response.data;
      });
    },
  }
};
</script>
